package com.gagakuai.bpm.config.busniess;

import com.gagakuai.bpm.rpcservice.openfeign.UserHttpApi;
import com.gagakuai.bpm.service.camunda.WorkflowTaskService;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/*
 * 根据问题项自动生成不符合项
 */


/*
 * 1、调用业务接口生成不符合项，返回生成后数据
 * 2、根据生成的不符合项发起纠正预防流程
 * 3、回写纠正预防流程实例ID
 */


@Slf4j
@Component
public class AutoGenerateNonconformity implements JavaDelegate {

    @Resource
    private UserHttpApi userHttpApi;

    @Resource
    private WorkflowTaskService workflowTaskService;

    @Override
    public void execute(DelegateExecution execution) throws Exception {
        try{
//            ResponseStatusDto<Void> responseStatusDto = userHttpApi.autoGenerateNonconformity(execution.getBusinessKey());
//            if(responseStatusDto.isSuccess()){
//                log.info("启动流程后回调接口成功");
//            }else{
//                log.info("启动流程后回调接口失败");
//            }
        }catch (Exception e){
            throw new Exception("回调自动生成不符合项接口异常 ", e);
        }
    }
}
